package com.pinyoumei.app.utils;

import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;

/**
 * Created by Administrator on 2020-07-14.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2020-07-14        Administrator             新增Person类
 * 2020-07-14        Administrator             增加sex属性
 */
public class StringColorUtils {
    public static SpannableStringBuilder setNumColor(String str,int color) {
        SpannableStringBuilder style = new SpannableStringBuilder(str);
        for (int i = 0; i < str.length(); i++) {
            char a = str.charAt(i);
            if (a >= '0' && a <= '9') {
                style.setSpan(new ForegroundColorSpan(color), i, i + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
        return style;
    }

}
